﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace WxLib.Common
{
    /// <summary>
    /// 微信访问签名响应模型
    /// </summary>
    public class WxAccessTokenResponse
    {
        public WxAccessTokenResponse()
        {
            access_date = DateTime.Now;
        }

        /// <summary>
        /// 获取到的凭证
        /// </summary>
        public string access_token { get; set; }
        /// <summary>
        /// 凭证有效时间，单位：秒
        /// </summary>
        public int expires_in { get; set; }
        /// <summary>
        /// 访问时间
        /// </summary>
        [JsonIgnore]
        public DateTime access_date { get; set; }

        /// <summary>
        /// 是否已过期
        /// </summary>
        /// <returns></returns>
        public bool IsExpired()
        {
            return access_date.AddSeconds(10) < DateTime.Now;
        }
    }
}
